package com.lipl.base.javaee.netty.nio;

import java.nio.ByteBuffer;

/**
 * @Auther: 15541
 * @Date: 2020/11/1 14:57
 * @Description:
 */
public class ReadOnlyBuffer {
    public static void main(String[] args) {

        ByteBuffer buffer = ByteBuffer.allocate(64);

        for (int i =0 ; i<64; i++){
            buffer.put((byte)i);
        }

        buffer.flip();

        ByteBuffer readOnlyBuffer = buffer.asReadOnlyBuffer();
        System.out.println(readOnlyBuffer.getClass());

        while (readOnlyBuffer.hasRemaining()){
            System.out.println(readOnlyBuffer.get());
        }
    }
}

